package cn.edu.hubu.hubuhotel.controller;

import cn.edu.hubu.hubuhotel.entity.Room;
import cn.edu.hubu.hubuhotel.service.RoomService;
import cn.edu.hubu.hubuhotel.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
public class RoomController {
    @Autowired
    private RoomService roomService;
    @RequestMapping("room/checkbyroomId")
    public ResultVO checkbyroomId(@RequestParam(defaultValue = "0") int roomId){
        System.out.println("~~~~~~~~~searchByroomId");
        ResultVO vo = roomService.checkRoombyroomId(roomId);
        return vo;
    }

    @RequestMapping("room/checkbyroomTypeId")
    public ResultVO checkroombyTypeId(@RequestParam(defaultValue = "0") int roomTypeId){
        System.out.println("~~~~~~~~~searchByroomTypeId");
        ResultVO vo = roomService.checkRoombyroomTypeId(roomTypeId);
        return vo;
    }

    @RequestMapping("room/checkbyprice")
    public ResultVO checkbyroomPrice(@RequestParam(defaultValue = "0") int price){
        System.out.println("~~~~~~~~~searchByroomPrice");
        ResultVO vo = roomService.checkRoombyroomPrice(price);
        return vo;
    }

    @RequestMapping("room/checkbyroomall")
    public ResultVO checkbyroomAll(@RequestParam(defaultValue = "0") int roomId,int price,int roomTypeId){
        System.out.println("~~~~~~~~searchByroomAll");
        ResultVO vo = roomService.checkRoomall(roomId,price,roomTypeId);
        return vo;
    }

    @RequestMapping("room/addroom")
    public ResultVO add(Room room){
        System.out.println("~~~~~~~~~addRoom");
        ResultVO vo = roomService.addRoom(room);
        return vo;
    }

    @RequestMapping("room/updateroom")
    public ResultVO update(Room room){
        System.out.println("~~~~~~~~~updateRoom");
        ResultVO vo = roomService.updateRoom(room);
        return vo;
    }

    @RequestMapping("room/deleteroom")
    public ResultVO delete(@RequestParam(defaultValue = "0") int roomId){
        System.out.println("~~~~~~~~~deleteroom");
        ResultVO vo = roomService.deleteRoom(roomId);
        return vo;
    }
    @RequestMapping("room/searchroom")
    public ResultVO searchroom(){
        ResultVO vo = roomService.searchRoom();
        return vo;
    }
}
